package com.example.app;

import com.example.bean.Dog;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Arrays;

public class App1 {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext1.xml");
        Object cat = applicationContext.getBean("cat");
        System.out.println(cat);
        Dog dog = applicationContext.getBean(Dog.class);
        System.out.println(dog);
//        获取beanDefinitionNames
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
//        我们发现如果没有给bean一个id spring会自动创建一个
        System.out.println(Arrays.toString(beanDefinitionNames));



    }
}
